package main.Link;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by s_shmakov on 26.03.14.
 */
public class CellRendererColorCheckBox extends DefaultTableCellRenderer {

        private JCheckBox box = new JCheckBox();
        private String rrow;

        public CellRendererColorCheckBox(String rrow) {
            super();
            this.rrow = rrow;
        }

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
            super.setBackground(isSelected ? new Color(175, 227, 193) : new Color(175, 227, 193));
            if (table.getValueAt(row, 0).equals(rrow)) {
                super.setBackground(isSelected ? new Color(175, 227, 193) : new Color(175, 227, 193));
            } else {
                super.setBackground(isSelected ? SystemColor.textHighlight : new Color(255, 255, 255));
            }
            box.setForeground(isSelected ? Color.black : Color.black);
            box.setSelected(((Boolean) value).booleanValue());

            return box;
        }

    }
